int convertFromHex(std::string hex)
{
	// Converts a HEX string to DEC int
	int value = 0; 
	int a = 0;
	int b = hex.length() - 1;
	for (; b >= 0; a++, b--)
	{
		if (hex[b] >= '0' && hex[b] <= '9')
		{
		value += (hex[b] - '0') * (1 << (a * 4));
		}
		else
		{
			switch(hex[b])
			{
			  case 'A':
			  case 'a':
				value += 10 * (1 << (a * 4));
				break;
			
			  case 'B':
			  case 'b':
				value += 11 * (1 << (a * 4));
				break;
			
			  case 'C':
			  case 'c':
				value += 12 * (1 << (a * 4));
				break;
			
			  case 'D':
			  case 'd':
				value += 13 * (1 << (a * 4));
				break;
			
			  case 'E':
			  case 'e':
				value += 14 * (1 << (a * 4));
				break;
			
			  case 'F':
			  case 'f':
				value += 15 * (1 << (a * 4));
				break;
			
			  default:
				  std::cout << "Error, invalid character(s) '" << hex[a] << "' in hex number" << std::endl;
				  break;
			} // end switch
		} // end else		
	} // end for
	return value;
}